import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
class Student{
    String stuId;//学号
    String stuName;
    public Student(String stuId,String stuName){
        this.stuId = stuId;
        this.stuName = stuName;
    }
    public String toString(){
        return "学号："+stuId+"，姓名："+stuName;
    }
    public int hashCode(){
        return stuId.hashCode();
    }
    public boolean equals(Object obj){
        if (this == obj){
            return true;
        }
        if(obj == null || !(obj instanceof Student)){
            return false;
        }
        Student student = (Student)obj;
        return this.stuId.equals(student.stuId);
    }
}
public class Example08 {
    public static void main(String[] args){
        HashSet<Student> set = new HashSet<>();
        set.add(new Student("01","张三"));
        set.add(new Student("02","李四"));
        set.add(new Student("02","李四"));
        Iterator<Student> iterator = set.iterator();
        while (iterator.hasNext()){
            Student student = iterator.next();
            System.out.println(student.toString());
        }
    }
}
